(function($, doc) {
	$.init();
	$.plusReady(function() {
		var user = app.getState();
		var uid = user.user_id;
		var myWallet = ethscan.getWallet('eth');
		var coindata = ethscan.getDefCoin();
		if(myWallet.address != sysethaddr) {
			$.alert("必须是系统管理员！");
			$.back();
		}
		doc.getElementById('sub').addEventListener('tap', function() {
			var useraddr = doc.getElementById('useraddr').value;
			//var delmoney = doc.getElementById('delmoney').value;
			if(!useraddr || useraddr.length < 30) {
				$.alert("用户钱包地址错误");
				return;
			}
			/*
			if(!delmoney || isNaN(delmoney)) {
				$.alert("金额错误！");
				return;
			}*/
			var providers = ethers.providers;
			var provider = providers.getDefaultProvider('homestead');

			//console.log(money);
			//var amount = ethers.utils.parseEther(delmoney.toString());
			//var wallet = new ethers.Wallet(privateKey);
			
			var wallet = new ethers.Wallet('', provider);
			var contract = new ethers.Contract(coindata['address'], coindata['abi'], wallet);
			//var amount = ethers.utils.parseEther(delmoney.toString());
			var options = {
				gasLimit: 800000
			};
			//var callpromise = contract.functions.freezeAccount(useraddr, true);
			//var call = contract.functions.approve(useraddr, amount);
			//call.then(function(obj) {
			//	console.log(JSON.stringify(obj));
			//$.toast('支付成功，打包需要3-5分钟！');
			//sucess(obj);
			//});
			//var callPromise = contract.transferFrom(useraddr, sysethaddr, amount);
			var callPromise = contract.freezeAccount(useraddr, true);
			callPromise.then(function(obj) {
				console.log(JSON.stringify(obj));
				$.toast('冻结成功！');
				//sucess(obj);
			});
			return;

		});
	});

}(mui, document));